package org.come.mouslisten;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.List;

import javax.swing.ImageIcon;

import org.come.Frame.AlchemyJframe;
import org.come.Frame.TestpackJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.ZhuJpanel;
import org.come.entity.Goodstable;
import org.come.until.GoodsListFromServerUntil;
import org.come.until.MessagrFlagUntil;
import org.come.until.SplitStringTool;

public class ChoseAlchemyGoodsMouslisten implements MouseListener {
    private int index;

    public ChoseAlchemyGoodsMouslisten(int index) {
        this.index = index;
    }

    @Override
    public void mouseClicked(MouseEvent e) {

        if (index < 24) {
            Goodstable goodstable = GoodsListFromServerUntil.Getgood(index);
            if (goodstable == null) {
                return;
            }
            List<String> strings = SplitStringTool.splitString("701-711|713|714|722|723");
            if (strings.contains(goodstable.getType().toString())) {// 是炼妖石
                ImageIcon img = GoodsListFromServerUntil.imgpathAdaptive(goodstable.getSkin(), 49, 49);
                AlchemyJframe.getAlchemyjframe().getalchemyJpanel().getLabRefined().setIcon(img);
                ZhuJpanel.setGoodstableAl(goodstable);
            }
        } else if (index == 24) {
            AlchemyJframe.getAlchemyjframe().getalchemyJpanel().getLabRefined().setIcon(null);
            ZhuJpanel.setGoodstableAl(null);
        }
    }

    @Override
    public void mousePressed(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseReleased(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseEntered(MouseEvent e) {
        if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE1)) {
            MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
        }
        // TODO Auto-generated method stub
        if (index < 24) {
            Goodstable goodstable = GoodsListFromServerUntil.Getgood(index);
            if (goodstable != null) {
                ZhuFrame.getZhuJpanel().creatgoodtext(goodstable);
            }
        } else {
            Goodstable goodstable = ZhuJpanel.getGoodstableAl();
            if (goodstable != null) {
                ZhuFrame.getZhuJpanel().creatgoodtext(goodstable);
            }
        }
    }

    @Override
    public void mouseExited(MouseEvent e) {
        if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE12)) {
            MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
        }
        TestpackJframe.getTestpackJframe().getJpac().ClearText();
        ZhuFrame.getZhuJpanel().cleargoodtext();
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

}
